package com.example.text.entity;

import lombok.Data;
import org.springframework.data.annotation.Id;  // 修正：使用Spring的@Id
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.time.LocalDateTime;

@Data
@Document(indexName = "news_index")
public class News {

    @Id
    private String id;

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")  // 修正：analyzer
    private String title;

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")  // 修正：analyzer
    private String content;

    @Field(type = FieldType.Date)
    private LocalDateTime createTime;

    public News() {
    }

    public News(String title, String content, LocalDateTime createTime) {
        this.title = title;
        this.content = content;
        this.createTime = createTime;
    }
}